package com.findweb.guava.service.impl;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.findweb.guava.TradeAccount;
import com.findweb.guava.service.ITradeAccountService;

@Service
public class TradeAccountService implements ITradeAccountService {
	
	public static int COUNT;
	
	
	public TradeAccount getTradeAccountById(String key) {
		
		System.out.println("invoke getTradeAccountById method one time");
		TradeAccount mock = new TradeAccount();
		mock.setId(key);
		mock.setBalance(10.0);
		mock.setOwner("zzm");
		return mock;
	}
	
	@Override
	@Cacheable(cacheNames="trades")
	public TradeAccount getTradeAccountById(String key,String owner,double balance) {
		
		System.out.println("invoke getTradeAccountById method :"+ (++COUNT));
		TradeAccount mock = new TradeAccount();
		mock.setId(key);
		mock.setBalance(balance);
		mock.setOwner(owner);
		return mock;
	}	

}
